//
//  ViewController.m
//  MorePlatformCeShiApp
//
//  Created by dsy123 on 2021/8/10.
//

#import "ViewController.h"
#import "LabelAdaptHeight.h"
#import "LabelView.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.translucent = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSArray *array = @[@{@"type" : @"a",
                         @"name" : @"aaaaaa"
    },
                       @{@"type" : @"b",
                         @"name" : @"bbbbb"
                       },
                       @{@"type" : @"c",
                         @"name" : @"ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
                       },
                       @{@"type" : @"d",
                         @"name" : @"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
                       },
                       @{@"type" : @"e",
                         @"name" : @"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
                       },
                       @{@"type" : @"f",
                         @"name" : @"fffff"
                       },
                       @{@"type" : @"g",
                         @"name" : @"ggggg"
                       },
                       @{@"type" : @"h",
                         @"name" : @"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"
                       },
                       @{@"type" : @"i",
                         @"name" : @"iiiii"
                       },
    ];
    
    NSInteger H = 0;
    for (NSInteger i = 0; i < array.count; i++) {
        
        if ([array[i][@"type"] isEqualToString:@"a"]) {
            CGFloat height = [LabelAdaptHeight getHeightByWidth:200 title:array[i][@"name"] font:[UIFont systemFontOfSize:17.0f]];
            UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, H, 200, height)];
            nameLabel.font = [UIFont systemFontOfSize:17.0f];
            nameLabel.text = array[i][@"name"];
            nameLabel.numberOfLines = 0;
            nameLabel.textAlignment = NSTextAlignmentCenter;
            [self.view addSubview:nameLabel];
            H = H + height;
        }
        else if ([array[i][@"type"] isEqualToString:@"b"]) {
            CGFloat height = [LabelAdaptHeight getHeightByWidth:200 title:array[i][@"name"] font:[UIFont systemFontOfSize:17.0f]];
            UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, H, 200, height)];
            nameLabel.font = [UIFont systemFontOfSize:17.0f];
            nameLabel.text = array[i][@"name"];
            nameLabel.numberOfLines = 0;
            nameLabel.textAlignment = NSTextAlignmentCenter;
            [self.view addSubview:nameLabel];
            H = H + height;
        }
       else if ([array[i][@"type"] isEqualToString:@"c"]) {
            CGFloat height = [LabelAdaptHeight getHeightByWidth:200 title:array[i][@"name"] font:[UIFont systemFontOfSize:17.0f]];
           LabelView *nameLabel = [[LabelView alloc] init];
           nameLabel.frame = CGRectMake(0, H, 200, height);
           nameLabel.backgroundColor = [UIColor yellowColor];
//            nameLabel.font = [UIFont systemFontOfSize:17.0f];
//            nameLabel.text = array[i][@"name"];
//            nameLabel.numberOfLines = 0;
//            nameLabel.textAlignment = NSTextAlignmentCenter;
            [self.view addSubview:nameLabel];
            H = H + height;
        }
       else if ([array[i][@"type"] isEqualToString:@"d"]) {
            CGFloat height = [LabelAdaptHeight getHeightByWidth:200 title:array[i][@"name"] font:[UIFont systemFontOfSize:17.0f]];
            UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, H, 200, height)];
            nameLabel.font = [UIFont systemFontOfSize:17.0f];
            nameLabel.text = array[i][@"name"];
            nameLabel.numberOfLines = 0;
            nameLabel.textAlignment = NSTextAlignmentCenter;
            [self.view addSubview:nameLabel];
            H = H + height;
        }
       else if ([array[i][@"type"] isEqualToString:@"e"]) {
            CGFloat height = [LabelAdaptHeight getHeightByWidth:200 title:array[i][@"name"] font:[UIFont systemFontOfSize:17.0f]];
            UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, H, 200, height)];
            nameLabel.font = [UIFont systemFontOfSize:17.0f];
            nameLabel.text = array[i][@"name"];
            nameLabel.numberOfLines = 0;
            nameLabel.textAlignment = NSTextAlignmentCenter;
            [self.view addSubview:nameLabel];
            H = H + height;
        }
       else if ([array[i][@"type"] isEqualToString:@"f"]) {
            CGFloat height = [LabelAdaptHeight getHeightByWidth:200 title:array[i][@"name"] font:[UIFont systemFontOfSize:17.0f]];
            UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, H, 200, height)];
            nameLabel.font = [UIFont systemFontOfSize:17.0f];
            nameLabel.text = array[i][@"name"];
            nameLabel.numberOfLines = 0;
            nameLabel.textAlignment = NSTextAlignmentCenter;
            [self.view addSubview:nameLabel];
            H = H + height;
        }
       else if ([array[i][@"type"] isEqualToString:@"g"]) {
            CGFloat height = [LabelAdaptHeight getHeightByWidth:200 title:array[i][@"name"] font:[UIFont systemFontOfSize:17.0f]];
            UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, H, 200, height)];
            nameLabel.font = [UIFont systemFontOfSize:17.0f];
            nameLabel.text = array[i][@"name"];
            nameLabel.numberOfLines = 0;
            nameLabel.textAlignment = NSTextAlignmentCenter;
            [self.view addSubview:nameLabel];
            H = H + height;
        }
        
        
    }
    
    
    
}


@end
